/*
 * 项目名称:    wms-server-jeecg
 * 创建人员:    DongPeng
 * 创建时间:    2023-09-21
 * copyright(c) 2022 无锡星智数服科技有限公司
 */
package org.jeecg.modules.dock.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.business.repertory.entity.vo.RepertoryTcVO;
import org.jeecg.modules.business.repertory.entity.vo.param.RepertoryTcParamVO;
import org.jeecg.modules.business.repertory.service.IWmsRepertoryService;
import org.jeecg.modules.dock.aspect.DockLog;
import org.jeecg.modules.dock.constant.SystemConstants;
import org.jeecg.modules.dock.entity.nest.NestBaseResponseVO;
import org.jeecg.modules.dock.entity.nest.StripTransferReceiveVO;
import org.jeecg.modules.dock.service.NestDockingService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 提供套裁调用
 *
 * @author DongPeng
 * @version 1.0.0
 * @date 2023-09-21
 * @description 类描述
 */
@AllArgsConstructor
@RestController
@Slf4j
@RequestMapping("/dock/nest")
@Api(tags = "套裁调用controller")
@DockLog(source = SystemConstants.NEST)
public class NestDockingController {

    private final NestDockingService nestDockingService;
    private final IWmsRepertoryService wmsRepertoryService;

    @PostMapping("/stripTransfer")
    @ApiOperation(value = "套裁-WMS发送条料调拨任务", notes = "套裁-WMS发送条料调拨任务")
    public NestBaseResponseVO stripTransfer(@RequestBody @Valid StripTransferReceiveVO stripTransferRequestVO) {
        return nestDockingService.scoringStorage(stripTransferRequestVO);
    }

    /**
     * 库存-套裁查询库存
     *
     * @param param
     * @param pageNo
     * @param pageSize
     * @return
     */
    @AutoLog(value = "库存-套裁查询库存")
    @ApiOperation(value = "库存-套裁查询库存", notes = "库存-套裁查询库存")
    @PostMapping(value = "/tc-list")
    public NestBaseResponseVO queryTcPageList(@RequestBody @Validated RepertoryTcParamVO param) {
        NestBaseResponseVO nestBaseResponseVO = new NestBaseResponseVO();
        try {
            List<RepertoryTcVO> list = wmsRepertoryService.listTcByPage(param);
            nestBaseResponseVO.setData(list);
            nestBaseResponseVO.setTarget("S");
            nestBaseResponseVO.setMsg("查询成功");
        }catch (Exception e){
            nestBaseResponseVO.setTarget("E");
            nestBaseResponseVO.setMsg(e.getMessage());
        }
        return nestBaseResponseVO;
    }
}
